package com.pine.admin.filter;

import com.pine.common.dto.Result;
import com.pine.common.exception.ApiException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author: Pine
 * @Date: 2018/6/29 下午12:19
 * @Email:771190883@qq.com
 */
@ControllerAdvice
public class GlobalExceptionHandler {

        @ExceptionHandler(value = Exception.class)
        @ResponseBody
        public Result defaultErrorHandler(HttpServletRequest req, ApiException e) throws Exception {

            return new Result(false,e.getCode(),e.getMessage());
        }

}
